﻿@{
    ViewBag.Title = "Index";
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>创伤病历</title>
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/ligerui-icons.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Gray/css/all.css" />
    <link rel="stylesheet" href="~/Content/css/common.css" />
    <link rel="stylesheet" href="~/Scripts/laydate/theme/default/laydate.css" />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/jquery.form.js"></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script type="text/javascript">
        var defaultSelpId = "@ViewBag.patientId";
        $(document).ready(function () {
            waitting1 = $.ligerDialog.waitting('加载中，请稍候...');
            $.ajax({
                url: "/TraumaCenter/FirstAid/GetPatientList", cache: false, success: function (data) {
                    var d = $.parseJSON(data);
                    if (d.Result == 1) {
                        var jsonData = $.parseJSON(d.Body);
                        $("#selPatientList").html('');
                        for (var i = 0; i < jsonData.length; i++) {
                            var htmlselected = defaultSelpId == jsonData[i].PATIENT_ID ? "selected=\"selected\"" : "";
                            $("#selPatientList").append("<option " + htmlselected + " value=" + jsonData[i].PATIENT_ID + ">" +
                                (IsEmpty(jsonData[i].PATIENT_NAME) ? "未知姓名" : jsonData[i].PATIENT_NAME) + "&nbsp;&nbsp;&nbsp;" +
                                (GetSex(jsonData[i].PATIENT_SEX)) + "&nbsp;&nbsp;&nbsp;" +
                                (IsEmpty(jsonData[i].PATIENT_AGE) ? "未知年龄" : jsonData[i].PATIENT_AGE + "岁") + "</option>");
                        }
                    }
                    selectPatient();
                    waitting1.close();
                },
                error: function () {
                    waitting1.close();
                    $.ligerDialog.error("程序错误");
                }
            });
            $(document).on("click", ".closeCls", function () {
                window.location.reload(true);
            });
        })
        function GetSex(id) {
            if (IsEmpty(id)) return "";
            switch (parseInt(id)) {
                case 0: return "女";
                case 1: return "男";
                case 2: return "未知性别";
                case 3: return "未说明性别";
                default: return "";
            }
        }
        function selectPatient() {
            if (!IsEmpty($("#selPatientList").val())) {
                var url = "/TraumaCenter/MedicalRecords/Traumamr?pid=" + $("#selPatientList").val();
                if (defaultSelpId != "") location.replace(url);
                $("#alink1").attr("href", url);
                $("#p1").show();
            } else {
                $("#p1").hide();
            }
        }
        function edit() {
            var id = $("#selPatientList").val();
            if (id == null) id = 0;
            var tit = parseInt(id) > 0 ? "编辑患者" : "新增患者";
            $.ligerDialog.open({
                height: 400,
                width: 520,
                title: tit,
                url: '/TraumaCenter/PatientList/Edit?Id=' + id,
                showMax: false,
                showToggle: false,
                showMin: false,
                isResize: false,
                slide: false,
                data: {},
                buttons: [{
                    text: '回调函数', onclick: function (i, d) {
                        window.location.reload(true);
                    }
                }],
                cls: "closeCls"
            }).max();
            $(".l-dialog-buttons").hide();
        }
    </script>
</head>
<body>
    <div style="font-size: 13px; width: 100%; height:80px; background-color: #f1f6f8;">
        <div style="float:left; margin-left:20px; margin-top:40px;">
            选择患者：<select style="width:200px;" id="selPatientList" name="selPatientList" onchange="selectPatient();"></select>
        </div>
    </div>
    <div style="font-size: 13px; width: 100%; height: 40px; background-color: #f1f6f8;">
        <p id="p1" style="margin-left:80px;"><a id="alink1" href="/TraumaCenter/MedicalRecords/Traumamr">进入病历</a></p>
    </div>
</body>
</html>